package com.traffic.api.filter.filter;

import java.util.Map;

import com.traffic.api.exception.ApiBizException;
import com.traffic.api.jedis.JedisClient;

public class AppkeyFilter implements IApiFilter {
	public static String cacheStart_user = "user_";

	public void validateFilter(Map<String, Object> params) throws ApiBizException {
		JedisClient client = JedisClient.getInstance();
		if ((params.get("appkey") == null) || ("".equals(params.get("appkey")))) {
			throw new ApiBizException(new Throwable("(api)appkey参数不能为空"));
		}

		boolean isExists = client.exists(cacheStart_user + params.get("appkey"));
		if (!(isExists))
			throw new ApiBizException(new Throwable("(api)您填写的appkey不存在"));
	}
}